/* Copyrights Security Engineering Research Group 
 * Author: Nauman (http://recluze.wordpress.com) 
 * 
 */

package edu.serg.mbar.ucon.meta;

import java.util.Vector;

/**
 * This class stores object information for an individual subject. It stores the
 * unique identification of the object (currently its path) and the rights that
 * can be exercised by the subject on this object.
 * 
 * 
 * @author Nauman (recluze.wordpress.com)
 * 
 */

public class ObjectInstance {
	/** The unique identification of the object */
	private String objectID;

	/** The exercisable rights on the object */
	private Vector<String> rights;

	public String getObjectId() {
		return objectID;
	}

	public void setObjectId(String object_id) {
		this.objectID = object_id;
	}

	/**
	 * Returns a clone of the rights that can be exercised by the subject.
	 * Modifications to this structure will be lost as a duplicate of the
	 * structure is returned and not the original one. This is to prevent
	 * modifications to the rights.
	 * 
	 * Use the other methods for modifications to this vector.
	 * 
	 */
	@SuppressWarnings("unchecked")
	public Vector<String> getRights() {
		return (Vector<String>) rights.clone();
	}

	/**
	 * Add a right to the object for the subject
	 * 
	 * @param right
	 *            Right to be added.
	 */
	public void AddRight(String right) {
		if (rights.indexOf(right) > -1)
			rights.add(right);
	}

	/**
	 * Revoke a right on an object. This is just a storage area. Any changes
	 * have to be communicated to the AccessManager for enforcement.
	 * 
	 * @param right
	 *            The right to be revoked.
	 */
	public void RevokeRight(String right) {
		rights.remove(rights.indexOf(right));
	}

	/**
	 * Create an object instance with an objectID
	 * 
	 * @param objectID
	 *            ID of the new object
	 */
	public ObjectInstance(String objectID) {
		super();
		this.objectID = objectID;
	}

}
